package net.hvacapp.cmvrfforandroid.ui.resource;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.view.View;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import net.hvacapp.cmvrfforandroid.AppManager;
import net.hvacapp.cmvrfforandroid.R;
import net.hvacapp.cmvrfforandroid.ui.BaseActivity;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_video_player)
public class VideoPlayerActivity extends Activity {

    @ViewById(R.id.vv_video)
    VideoView mVideoView;

    @ViewById(R.id.tv_navigation_title)
    protected TextView mTitle;
    @ViewById(R.id.tv_navigation_back)
    protected TextView mBack;

    private String mUrl;

    /**
     * 页面加载完后执行
     */
    @AfterViews
    protected void viewDidLoad() {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        AppManager.getAppManager().addActivity(this);

        initData(getIntent());
    }


    private void initData(Intent intent) {
        String title = intent.getStringExtra("title");
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mTitle.setText(title);

        mUrl = intent.getStringExtra("url");

        mVideoView.setMediaController(new MediaController(this));
        mVideoView.setVideoURI(Uri.parse(mUrl));
        mVideoView.start();
        mVideoView.requestFocus();

    }



}
